package fiziksobject;

import physics.Forcer;
import physics.Vector;
import physics.physicsobject;
import physics.Vector.Type;

public class magneticField implements Forcer {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private double B;
	private boolean into;
	
	public magneticField(double fieldStrength, boolean in){
		B = fieldStrength;
		into = in;
		
	}
	public Vector[] getForces(physicsobject p) {
		if(B==0) {
			Vector[] ret = {new Vector().toType(Type.FORCE_MAGNETIC)};
			return ret;
		}
		double q = p.getCharge();
		Vector vel = p.getVelocity();
		Vector normal = new Vector(vel.getLocation(),Type.FORCE_MAGNETIC,-vel.getYMag(),vel.getXMag());
		Vector[] ret = {normal.multiply(B * q * (into ? 1 : -1))};
		return ret;
	}
	
	public double getStrength() {
		return B;
	}
	
	public void setStrength(double b) {
		this.B = b;
	}
	
	public boolean getInto() {
		return into;
	}
	
	public void setInto(boolean b) {
		into = b;
	}

}
